// Copyright  Author(https://github.com/LiuShuKu). All Rights Reserved.

// Copyright (c)  2024 LiuShuKu
// Project Name :   balance
// Author       :   liushuku@yeah.net

// Package okx 欧意相关 .
package okx

import (
	"context"
	"fmt"
	"github.com/gogf/gf/v2/net/gclient"
	"strconv"
	"time"
	"tronServer/internal/model/domain"
)

const (
	okxURL = "https://www.okx.com/v4/c2c/express/price?crypto=USDT&fiat=CNY&side=sell&t=%s"
)

type okx struct {
}

var Okx = &okx{}

// UsdtToCnyRate 获取USDT兑人民币汇率
func (o *okx) UsdtToCnyRate(ctx context.Context) (okx *domain.OkxData, err error) {
	err = gclient.New().GetVar(ctx, fmt.Sprintf(okxURL, strconv.Itoa(int(time.Now().Unix())))).Scan(&okx)
	return
}
